﻿/****************************************************************************
Copyright (c) 2014-2015 凌惊雪 微信:Lingjingxue 邮箱:lingjingxue@sina.com QQ:271487457

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

using ServerBase.Other;
using ServerBase.Protocol;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UtilLib;

namespace ServerBase.Config
{
    public enum EServerPlatform
    {
        开发 = 0,
        内网测试 = 1,
        外网测试 = 2,
    }
    //全局配置
    public class GlobalConfigExt
    {
        public int GlobalId;
        public GlobalConfig SettBase;
        public string Value;
        public bool ValueBool;
        public int ValueInt;
        public long ValueLong;
        public float ValueFloat;
        public List<string> ValueListString;
        public List<int> ValueListInt;
        public List<float> ValueListfloat;
        public List<List<int>> ValueListListInt;
        public GlobalConfigExt(GlobalConfig v)
        {
            GlobalId = v.GlobalId;
            SettBase = v;
            Value = v.Value;
            ValueBool = Value.ToBool();
            ValueInt = Value.ToInt();
            ValueLong = Value.ToLong();
            ValueFloat = Value.ToFloat();
            ValueListString = Value.ToListString(Conf.ConfListSeparator);
            ValueListInt = Value.ToListInt(Conf.ConfListSeparator);
            ValueListfloat = Value.ToListFloat(Conf.ConfListSeparator);
            ValueListListInt = Value.ToListListInt(Conf.ConfDictionarySeparator1, Conf.ConfDictionarySeparator2);
        }
    }
    //掉落
    public class ConfigDropExt
    {
        public int Id;
        public ConfigDrop SettBase;
        public int DropType; //掉落类型
        public Dictionary<int, int> Num = new Dictionary<int, int>(); //掉落数量
        public List<List<int>> DropPoll; //掉落池
        public Weighted<int> RateNum;
        public Dictionary<CLS_AwardItem, int> DictDropPoll;
        public Weighted<CLS_AwardItem> RateDropPoll;
        public ConfigDropExt(ConfigDrop v)
        {
            Id = v.Id;
            SettBase = v;
            DropType = v.DropType;
            Num = v.Num;
            DropPoll = v.DropPoll;
            RateNum = new Weighted<int>(v.Num);
            DictDropPoll = v.DropPoll.ToDictAwardDrop();
            RateDropPoll = new Weighted<CLS_AwardItem>(DictDropPoll);
        }
    }

    //房间
    public class ConfigRoomExt
    {
        public string Id;
        public ConfigRoom SettBase;
        public Dictionary<string, int> DictItems = new Dictionary<string, int>();
        public Dictionary<string, int> DictEquips = new Dictionary<string, int>();
        public Dictionary<string, int> DictNpcs = new Dictionary<string, int>();
        public ConfigRoomExt(ConfigRoom v)
        {
            Id = v.Id;
            SettBase = v;
            foreach (var item in v.Items)
            {
                DictItems.TryGetValue(item[0], out var oldcount);
                DictItems[item[0]] = oldcount + item[1].ToInt();
            }
            foreach (var item in v.Equips)
            {
                DictEquips.TryGetValue(item, out var oldcount);
                DictEquips[item] = oldcount + 1;
            }
            foreach (var item in v.Npcs)
            {
                DictNpcs.TryGetValue(item, out var oldcount);
                DictNpcs[item] = oldcount + 1;
            }
        }
    }
    //武器种类
    public class ConfigWeaponTypeExt
    {
        public string Id;
        public ConfigWeaponType SettBase;
        public List<ConfigCbtAction> ListActions = new List<ConfigCbtAction>();
        public EUsageType UsageType = EUsageType.扑击格斗;
        public ConfigWeaponTypeExt(ConfigWeaponType v)
        {
            Id = v.Id;
            SettBase = v;
            UsageType = (EUsageType)v.UsageType;
            foreach (var item in v.Verbs)
            {
                if (item.IsNullOrEmpty())
                {
                    continue;
                }
                ListActions.Add(Conf.ConfCbtAction[item]);
            }
        }
    }
    //种族
    public class ConfigRaceExt
    {
        public string Id;
        public ConfigRace SettBase;
        public List<ConfigCbtAction> ListActions = new List<ConfigCbtAction>();
        public ConfigRaceExt(ConfigRace v)
        {
            Id = v.Id;
            SettBase = v;
            foreach (var item in v.Actions)
            {
                if (item.IsNullOrEmpty())
                {
                    continue;
                }
                ListActions.Add(Conf.ConfCbtAction[item]);
            }
        }
    }

}